<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <script src="./js/vue.js"></script>
</head>

<body>
  <div id="app">
    <div>
      <label>账号：
        <input type="text" v-model="username">
      </label>
    </div>
    <div>
      <label>密码：
        <input type="text" v-model="password">
      </label>
    </div>
    <div>
      <label>保存30天：
        <input type="checkbox" v-model="remember">
      </label>
    </div>
    <div>
      <button @click="onLogin">登录系统</button>
    </div>

  </div>

  <script>

    new Vue({
      el: '#app',
      data: {
        username: '',
        password: '',
        remember: false
      },
      methods: {
        onLogin() {
          /* if (this.username == '') {
            alert('账号不能为空')
            return;
          }
          console.log(111) */
          let ret = []
          for (let key in this.$data) {
            // if (this[key] == '' && typeof this[key] != "boolean") {
            if (this[key] === '') {
              ret.push(1)
            }
          }
          if (ret.length > 0) {
            alert('输出的信息不完整请认真填写')
            return;
          }

          console.log(this.$data)




        }
      }
    })
  </script>
</body>

</html>